var gmpUtil = new GmpUtil();
var gmpLoginBizSuccess;
var gmpLogoutBizSuccess;
var gmpBizError;
var authKey;

function GmpUtil(){

};

GmpUtil.prototype.loginGmp = function(loginBizSuccess, bizError){
	gmpLoginBizSuccess = loginBizSuccess;
	gmpBizError = bizError;
	GmpAuthD.loginGmp(GetFunctionName(gmpLoginSuccessCallback), GetFunctionName(gmpErrorCallback));
};

GmpUtil.prototype.getAuthInfo = function(successCallback, bizError){
	gmpLoginBizSuccess = successCallback;
	gmpBizError = bizError;
	GmpAuthD.getAuthInfo(GetFunctionName(gmpLoginSuccessCallback), GetFunctionName(gmpErrorCallback));
};

GmpUtil.prototype.writeFile = function(fileName, content){
	GmpAuthD.writeFile(fileName, content);
};

GmpUtil.prototype.getRegistraionId = function(successCallback, bizError){
	GmpAuthD.provision(GetFunctionName(successCallback), GetFunctionName(bizError));
};

GmpUtil.prototype.provision = function(successCallback, bizError){
	GmpAuthD.provision(GetFunctionName(successCallback), GetFunctionName(bizError));
};

function writeFileCallback(errorMessage){
	gmpBizError(errorMessage);
}

GmpUtil.prototype.logoutGmp = function(logoutBizSuccess, bizError){
	authKey = "";
	gmpLogoutBizSuccess = logoutBizSuccess;
	gmpBizError = bizError;
	GmpAuthD.logoutGmp(GetFunctionName(gmpLogoutSuccessCallback), GetFunctionName(gmpErrorCallback));
};
//GmpUtil.prototype.requestToGmp = function(logoutBizSuccess, bizError){
//	this.logoutSuccessCallback = loginBizSuccess;
//	gmpBizError = bizError;
//	GmpAuthD.logoutGmp(gmpLogoutSuccessCallback, gmpErrorCallback);
//};

function gmpLoginSuccessCallback(key){
	authKey = key;
	gmpLoginBizSuccess(authKey);
}

function gmpLogoutSuccessCallback(message){
	preference.putString("authKey", "empty");
	gmpLogoutBizSuccess(message);
}
function gmpErrorCallback(errorMessage){
	gmpBizError(errorMessage);
}
